package com.example.flowabledemo.config.db;

import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;

/**
 * @description 废弃多数据源，但是保留该配置
 * 2020年12月5日21:48:47
 */
//@Configuration
@Deprecated
public class TransactionConfig {

  @Autowired
  @Qualifier("dataSource")
  private DataSource dataSource;
  @Autowired
  @Qualifier("flowableDataSource")
  private DataSource flowableDataSource;

  @Primary
  @Bean
  public DataSourceTransactionManager transactionManager() {
    DataSourceTransactionManager transactionManager = new DataSourceTransactionManager();
    transactionManager.setDataSource(dataSource);
    return transactionManager;
  }


  @Bean
  public DataSourceTransactionManager flowableTransactionManager() {
    DataSourceTransactionManager transactionManager = new DataSourceTransactionManager();
    transactionManager.setDataSource(flowableDataSource);
    return transactionManager;
  }

}
